package com.liuguang.redis.controller;

import com.liuguang.api.redis.RedisService;
import com.liuguang.common.pojo.CommonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName: TestRedisController
 * @Description：
 * @Author: wanghr
 * Date: 2:55 PM 2020/11/6
 * Version: 1.0
 */
@RestController
@RequestMapping("/api/redis")
public class TestRedisController {

    @Autowired
    private RedisService redisService;

    @RequestMapping("/list")
    public CommonResult testList() {
        for (int i = 1; i <= 3; i++) {
            redisService.saveToList("111", i + "111");
        }
        return CommonResult.success();
    }

    @RequestMapping("/list1")
    public CommonResult testList1() {
        for (int i = 1; i <= 3; i++) {
            redisService.deleteBykey("111");
        }
        return CommonResult.success();
    }

    @RequestMapping("/list3")
    public CommonResult testList2() {
        CommonResult list = redisService.getList("111");
        Object data = list.getData();
        return CommonResult.success("成功", data);
    }
}
